package com.aco.party.web.validator.system;

import com.aco.party.web.command.system.EditEventCommand;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * Created by WangShijun on 2016/3/8.
 */
public class EditEventValidator implements Validator {
    @Override
    public boolean supports(Class<?> aClass) {
        return EditEventCommand.class.isAssignableFrom(aClass);
    }

    @Override
    public void validate(Object o, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventZhubanfang", "error.eventZhubanfang.empty", "主办方不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventLocation", "error.eventLocation.empty", "地址不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventStartTime", "error.eventStartTime.empty", "开始日期不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventEndTime", "error.eventEndTime.empty", "结束日期不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventName", "error.eventName.empty", "活动名称不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventQianyan", "error.eventQianyan.empty", "前言不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventThumImg", "error.eventThumImg.empty", "活动缩略图不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventProcess", "error.eventProcess.empty", "流程不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventInvited", "error.eventInvited.empty", "拟邀嘉宾不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventDesc", "error.eventDesc.empty", "联系方式不能为空");

        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eventLinks", "error.eventLinks.empty", "合作伙伴不能为空");
    }
}
